/**
 * 
 */
package com.toidep.entities;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.toidep.api.ParseJSON;
import com.toidep.config.Constants;
import com.toidep.utilities.StringUtility;

public class VideoEntity {

	private String id;
	private String caption;
	private String title;
	private String totalView;
	private String totalComment;
	private String thumb;
	private String duration;
	private String url;
	private String created;
	private String modelName;
	private String modelDisplay;
	private String modelIcon;
	private ArrayList<String> comments;
	private ArrayList<TagEntity> tags;
	
	private boolean isPayment; 
	
	public VideoEntity() {
		// TODO Auto-generated constructor stub
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCaption() {
		return caption;
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTotalView() {
		return totalView;
	}

	public void setTotalView(String totalView) {
		this.totalView = totalView;
	}

	public String getTotalComment() {
		return totalComment;
	}

	public void setTotalComment(String totalComment) {
		this.totalComment = totalComment;
	}

	public String getThumb() {
		return thumb;
	}

	public void setThumb(String thumb) {
		this.thumb = thumb;
	}

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getCreated() {
		return created;
	}

	public void setCreated(String created) {
		this.created = created;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public String getModelDisplay() {
		return modelDisplay;
	}

	public void setModelDisplay(String modelDisplay) {
		this.modelDisplay = modelDisplay;
	}

	public String getModelIcon() {
		return modelIcon;
	}

	public void setModelIcon(String modelIcon) {
		this.modelIcon = modelIcon;
	}

	public ArrayList<String> getComments() {
		return comments;
	}

	public void setComments(ArrayList<String> comments) {
		this.comments = comments;
	}

	public ArrayList<TagEntity> getTags() {
		return tags;
	}

	public void setTags(ArrayList<TagEntity> tags) {
		this.tags = tags;
	}
	
	/**
	 * @return the isPayment
	 */
	public boolean isPayment() {
		return isPayment;
	}

	/**
	 * @param isPayment the isPayment to set
	 */
	public void setPayment(boolean isPayment) {
		this.isPayment = isPayment;
	}

	public void setInfo(JSONObject jsonObject) {
		
		this.id = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_ID);
		this.title = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TITLE);
		this.caption = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_CAPTION);
		this.thumb = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_VIDEO_THUMBS).replace(" ", "%20").replace("(", "%28").replace(")", "%29");
		this.totalView = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_VIEW);
		this.totalComment = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_COMMENT);
		this.duration = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_VIDEO_DURATION);
		this.url = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_VIDEO_URL);
		this.created = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_CREATED);
		this.modelDisplay = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_MODEL_DISPLAY);
		this.modelName = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_MODEL_NAME);
		this.modelIcon = StringUtility.parseImageUrl(ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_MODEL_ICON));
		
		JSONArray tagArray = ParseJSON.getJsonArray(jsonObject, Constants.PARAM_RESPONSE_TAGS);
		this.tags = ParseJSON.getAllTagObject(tagArray);
		
		this.isPayment = (ParseJSON.getIntValue(jsonObject, "is_fee") == 1);
	}
	
}
